package com.zxy.controller;

import com.zxy.model.Permissions;
import com.zxy.model.PermissionsQuery;
import com.zxy.service.PermissionsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


import java.util.List;

@RestController
@RequestMapping("/api/permissions")
public class PermissionsController {
    @Autowired
    PermissionsService permissionsService;

    @GetMapping
    public List<Permissions> select(PermissionsQuery query) {

        return permissionsService.select(query);
    }

    @PostMapping
    public int insert(@RequestBody Permissions permissions) {
        return permissionsService.insert(permissions);
    }

    @PutMapping
    public int update(@RequestBody Permissions permissions) {
        return permissionsService.update(permissions);
    }

    @DeleteMapping
    public int delete(Integer id) {
        return permissionsService.delete(id);
    }

    @GetMapping("/byrid")
    public List<Permissions> selectRoleId(Integer id) {
        return permissionsService.selectRoleId(id);
    }

    @GetMapping("/byuid")
    public List<Permissions> selectUserId(Integer id) {
        return permissionsService.selectUserId(id);
    }

}
